<!DOCTYPE html>
<html>
    <head>
        <title>Django Server Sent Events - Test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            var source = new EventSource('/events2/');
            var events_dom = $("#events");
            var greeting_dom = $("#greeting");

            source.addEventListener('message', function(e) {
                greeting_dom.html("<div>" + e.data + "</div>");
            });

            source.addEventListener("date", function(e) {
                events_dom.append("<div>" + e.data + "</div>");
            });
        });
        </script>
    </head>
    <body>
        <h2>Events emited by server</h2>
        <div id="greeting">
        </div>
        <div id="events">
        </div>
    </body>
</html>
